# template elements
2018-04-18
Bobae Kang
(Bobae.Kang@illinois.gov)
Source: R Markdown
“R Markdown is a file format for making dynamic documents with R. An R Markdown document is written in markdown (an easy-to-write plain text format) and contains chunks of embedded R code.”
- Garret Grolemund from R Studio
rmarkdown
yaml header
knit and prevew
knit options
preview options
markdown
Headers
# Header 1
## Header 2
### Header 3
Font types
_italic_ __bold__
*italic* **bold**
~~strikethrough~~
superscript^2^
Lists
Unordered list | Ordered list
|
* Item 1 | 1. Item 1
* Item 1a | 1. Item 1a
* Item 2 | 2. Item 2
+ Item 2a | 1. Item 2a
- Item 2b | 2. Item 2b
Mixed list
1. Item 1
* Item 1a
* Item 2
1. Item 2a
+ Item 2b
Hyperlinks
[text with hyperlink](http://link.path)
Images


Blockquotes
> A line of text following the "> " is a blockquote.
A line of text following the “> ” is a blockquote.
Horizontal line/page break
More then three asteriks or dashs
***
******
------
Math equations
Inline math equations look like: $y = (x + 1)^2$
A block of math equations look like:
$$y = x^2 + 2x + 1$$
R code chunk
Insert a new code chunk
Ctrl + Alt + iRun code chunks
Ctrl + Enterknitr::include_graphics()Using knitr::include_graphics()
# image on the web using URL
knitr::include_graphics("https://www.some-image.com/image1.jpg")
# image in the project folder using a relative path
knitr::include_graphics("images/image2.png")
knitr options for image
fig.height and fig.widthfig.dimknitr::kable()DT::datatable()default data frame example
kable example
datatable example
Source: Wikimedia Commons
---
title: "My first R Markdown document"
output: html_document
---
---
title: "My first R Notebook"
output: html_notebook
---
“An R Notebook is an R Markdown document with chunks that can be executed independently and interactively, with output visible immediately beneath the input.”
- “R Notebooks”, RStudio
htmlwidgets include:
plotly and highcharter for interactive visualizationsleaflet for interactive mapsDT for interactive data tableshtmlwidgets for R website to find out more---
title: "My PDF document"
output: pdf_document
---
---
title: "My word document"
output: word_document
---
“RPubs is a quick and easy way to disseminate data analysis and R code and do ad-hoc collaboration with peers.”
- RStudio Team
Source: Wikimedia Commons
ioslides_presentation (HTML)revealjs::revealjs_presentation (HTML)slidy_presentation (HTML)beamer_presentation (PDF)---
title: "My first ioslide presentation"
output: ioslides_presentation
---
ioslides output format is built into RStudio# and ## headingsioslides, read the “Presentations with ioslides” article on RStudioSlides example
---
title: "My first ioslide presentation"
author: Bobae Kang
date: April 18, 2018
output: ioslides_presentation
---
# First section
## Normal slide
- Item one
- Item two
## Another slide | With a subtitle
This slide has a two-column layout
----

Embed sample ioslides here
---
title: "My first revealjs presentation"
output: revealjs::revealjs_presentation
---
revealjs R package, it is possible to use R Markdown (and its syntax) to generate slides using reveal.js, a JavaScript library for interactive slides in HTML
revealjs, read the “Presentations with reveal.js” article on RStudioEmbed sample revealjs here
slidy
output: slidy_presentation in the YAML headerbeamer
output: beamer_presentationxaringan
output: xaringan::moom_readerSource: R Studio
“Shiny is an open source R package that provides an elegant and powerful web framework for building web applications using R. Shiny helps you turn your analyses into interactive web applications without requiring HTML, CSS, or JavaScript knowledge.”
- RStudio.com
runtime: shiny and output: html_document or output: ioslids_presentationSource: Wikimedia Commons
_site.yml file in the same folder as individual documents to be put together_site.yml specifies the name and the routing structure of the resulting website_site.yml and all HTML documents ready, run rstudio::render_site() to generate the website“GitHub Pages is a static site hosting service designed to host your personal, organization, or project pages directly from a GitHub repository.”
-“What is GitHub Pages?”, GitHub Help
bookdown package, built on R Markdown, facilitates writing books and long articles/reports.
bookdown publication is made downloadable in PDF, EPUB and MOBI formatsbookdown package website to find out morebookdown: Authoring Books and Technical Documents with R Markdown for a comprehensive guide for bookdown
bookdownblogdown is a package to generate static websites using R Markdown and the Hugo open-source framework for building websitesblogdown examplesblogdown: Creating Websites with R Markdown for a comprehensive guide for blogdown
Source: Giphy
References
![]()
Source: Wikimedia.org